#include <stdio.h>
#include <stdlib.h>

#include "sqlite3.h"
#include "GB28181_db.h"

/**
* @brief 执行SQL语句的实体函数
*/
static int sqlite3_exec_cmd(IN log_obj *obj)
{
	char *zErrMsg = NULL;
	int rc = 0;
	
	/*open database*/
	rc = sqlite3_open(obj->log_database_path, &obj->db);
	if(SQLITE_OK != rc)
	{
		RPTERR("Can't open database:%s, errMsg:%s", obj->log_database_path, sqlite3_errmsg(obj->db));
		return -1;
	}

	/* Execute SQL statement */
	rc = sqlite3_exec(obj->db, obj->SQL_cmd, obj->call_back, (void *)obj->data, &zErrMsg);
	if( rc != SQLITE_OK )
	{
		RPTERR("SQL error: %s\n", zErrMsg);
		sqlite3_free(zErrMsg);
		sqlite3_close(obj->db);
		return -1;
	}

	sqlite3_close(obj->db);
	
	return 0;
}


/*_*/

